import example_pb2

# 创建Person实例
person = example_pb2.Person()

# 填充字段
person.name = "John Doe"
person.id = 1234
person.email = "johndoe@example.com"

# 打印序列化后的二进制数据
print(person.SerializeToString())

# 反序列化
data = person.SerializeToString()
new_person = example_pb2.Person()
new_person.ParseFromString(data)

# 输出反序列化后的对象信息
print(f"Name: {new_person.name}")
print(f"ID: {new_person.id}")
print(f"Email: {new_person.email}")